//
//  QPExperienceViewController.swift
//  QianPingNew
//
//  Created by Apple on 2019/5/14.
//  Copyright © 2019 Apple. All rights reserved.
//

import UIKit

class QPExperienceViewController: BaseViewController {
    var pageView : TLPageView!
    var colors : [UIColor] = [UIColor.yellow,UIColor.red,UIColor.brown,UIColor.blue]
    var titles : [String] = ["关注", "发现", "附近"]
    let itemW = (IPhone.screenWidth - 135) / 2
    
    lazy var rightItem: UIButton = {
        let btn = UIButton(type: .custom)
        btn.frame = CGRect(x: 0, y: 0, width: itemW, height: 100)
        btn .addTarget(self, action: #selector(searchBtnClick), for: .touchUpInside)
        btn.setImage(UIImage(named: "More"), for: .normal)
        btn.setImage(UIImage(named: "More"), for: .highlighted)
        return btn
    }()
    lazy var leftItem: UIView = {
        let view = UIView()
        view.frame = CGRect(x: 0, y: 0, width: itemW, height: 100)
        return view
    }()
    override func viewDidLoad() {
        Base_isShowNavigation = false
        super.viewDidLoad()
        setupUI()
    }
    func setupUI() {
        var controllers = [UIViewController]()
        for i in 0..<3{
            let controller = UIViewController()
            controller.title = titles[i]
            controller.view.backgroundColor = colors[i % 4]
            controllers.append(controller)
            
            
        }
        
        let option:[TLPageViewOption] = [.menuHeight(50),
                                         .menuItemMargin(5),
                                         .menuItemFont(UIFont.systemFont(ofSize: 15)),
                                         .menuItemColor(UIColor(red: 146 / 255.0, green: 146 / 255.0, blue: 146 / 255.0, alpha: 1.0)),
                                         .menuItemSelectedScale(1.2),
                                         .menuItemSelectedColor(UIColor(red: 33 / 255.0, green: 33 / 255.0, blue: 33 / 255.0, alpha: 1.0)),
                                         .rightItem(rightItem),
                                         .leftItem(leftItem),
                                         .TileViewCanScoll(false),
                                         .menuBottmonLineWidth(10)
        ]
        
        pageView = TLPageView(viewControllers: controllers, pageViewOptions: option)
        
        view.addSubview(pageView)
        pageView.frame = CGRect(x: 0, y: IPhone.statusHight, width: view.frame.size.width, height: view.frame.size.height - IPhone.statusHight)
        
        pageView.moveTo(index: 1, animated: false)
    }
    @objc private func searchBtnClick() {
        
    }

}
